package org.word.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

import java.util.Collections;
import java.util.List;

/**
 * Swagger文档页面配置
 *
 * @author XiuYin.Cui
 * @date 2018/1/11.
 */
@Configuration
public class SwaggerDocumentationConfig {

    ApiInfo apiInfo() {
        return new ApiInfoBuilder()
              .title("Swagger配置转为Word工具")
              .description("这是一个能将Swagger的原生文件转换为Word文档的工程")
              .license("Apache 2.0")
              .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
              .termsOfServiceUrl("")
              .version("0.0.1")
              .contact(new Contact("", "", "angel0213@163.com"))
              .build();
    }

    @Bean
    public Docket customImplementation() {
        return new Docket(DocumentationType.SWAGGER_2)
              .select()
              .apis(RequestHandlerSelectors.basePackage("org.word.controller")).build()
              .directModelSubstitute(org.joda.time.LocalDate.class, java.sql.Date.class)
              .directModelSubstitute(org.joda.time.DateTime.class, java.util.Date.class)
              .apiInfo(apiInfo());
    }

}
